<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>印章管理</title>
</head>
<body class="layui-layout-body">
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="body_right">
            <h4 class="nav_title">印章管理
            		<a href="javascript:openwinx('添加印章','/admin/devices/form.htm','600','450');" class="add_btn">添加</a>
            </h4>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		        <ul class="layui-tab-title">
		            <li lay-id="INIT">待分配</li>
		            <li lay-id="EFFECTIVE">已分配</li>
		            <li class="layui-this">已失效</li>
		        </ul>
		        <div class="layui-tab-content" >
            			<div class="layui-tab-item layui-show">
            			
            			<div class="layui-row">
					        <form class="layui-form no_bordertop" action="/admin/devices/deadList.htm">
					          <div class="layui-input-inline">
					            <input type="text" name="devicesCode" value="${query.devicesCode}" placeholder="请输入设备编号" autocomplete="off" class="layui-input">
					          </div>
					          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
					        </form>
					    </div>
            			
			            <table class="layui-table  layui-form" lay-even="" lay-skin="nob">
			                <thead>
			                <tr>
			                	<th>公司名称</th>
			                	<th>设备编号</th>
			                    <th>型号</th>
			                    <th>开通日期</th>
			                    <th>失效日期</th>
			                    <th>使用次数</th>
			                    <th>操作</th>
			                </tr>
			                </thead>
			                <tbody>
			                		<#list pm.datas as item>
			                    <tr>
			                    		<td align="left">${item.company.companyName}</td>
			                    		<td>${item.devicesCode}</td>
			                        <td>${item.model}</td>
			                        
			                        <td>
			                        		<#if item.bindingTime??>
			                        		${item.bindingTime?string('yyyy-MM-dd')}
			                        		</#if>
			                        </td>
			                        <td>
			                        		<#if item.expireDate??>
			                        		${item.expireDate?string('yyyy-MM-dd')}
			                        		<#else>
			                        		永久
			                        		</#if>
			                        	</td>
			                        
			                        <td>${item.useTimes}</td>
			                        <td class="allbox_a">
			                        		<a href="javascript:openwinx('设备详情','/admin/devices/info.htm?devicesId=${item.devicesId}',800,600);">查看</a>
			                        	</td>
			                    </tr>
			                    </#list>
			                </tbody>
			            </table>
			            <@p.page pm=pm></@p.page>
            			
            		    </div>
        			</div>
    			</div>

        </div>
     </div>


isActivity
<script>
layui.use(['form', 'layedit', 'laydate','element'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,element = layui.element
  
  
  element.on('tab(docDemoTabBrief)', function(elem){
	  		var id = $(this).attr('lay-id');
	  		if(id == 'INIT'){
	  		 	location.href='/admin/devices/initList.htm';
	  		}
	  		
	  		if(id == 'EFFECTIVE'){
	  		 	location.href='/admin/devices/effeList.htm';
	  		}
	  });
  
  //监听指定开关
  form.on('switch(isActivity)', function(data){
  	
  	var devicesId = $(this).val();
  	
  	if(this.checked){
  		ifComfirm('确认是否启用？','/admin/devices/changeActivateState.htm',{devicesId:devicesId});
  	}else{
  		ifComfirm('禁用后设备将无法使用，确认禁用？','/admin/devices/changeActivateState.htm',{devicesId:devicesId});
  	}
  });
  
});


function ifComfirm(title,url,parms){

    layer.confirm(title, {icon: 3, title:'提示'}, function(index){
		  //do something
		  if(url){
			  
			  $.ajax({
	      			type:"POST", 
	      			url:url,
	      			data:parms ,
	      			success:function(result) {
			      
			      		if(result.code=='1'){
			      			layer.msg('操作成功');
			      		}else{
			      		 	layer.msg(result.msg);
			      		}
			      
			    	 	} 
			    }); 
		  }
	    layer.close(index);
	});

}

</script>

</body>
</html>